# _*_ coding : utf-8 _*_
# @Time : 2023/8/26 19:09
# @Author : 寻梦
# @File : 12_代理的基本使用
# @Project : code
import urllib.request

base_url="http://www.cip.cc/"
headers={
    "User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36 SLBrowser/8.0.1.5162 SLBChan/30"
}
# 请求对象的定制
request=urllib.request.Request(url=base_url,headers=headers)

# 创建代理handler
proxies={
    'http':'115.207.24.27:15563'
}
handler=urllib.request.ProxyHandler(proxies=proxies)

# 创建handler
opener=urllib.request.build_opener(handler)

# 获取响应对象
response=opener.open(request)

# 获取响应内容
content=response.read().decode("utf-8")

print(content)